home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / STREAM13.ARJ / OVRDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-18  |  1KB  |  70 lines

  1. {$B-}   { Use fast boolean evaluation. }
  2.  
  3. program ovrdemo;
  4.  
  5. { Program to demonstrate use of two overlay files. }
  6.  
  7. uses
  8.   overlay,objects,streams,
  9.   ovr1,ovr2;
  10.  
  11. {$O ovr1}
  12. {$O ovr2}
  13.  
  14. type
  15.   PMessageStream = ^TMessageStream;
  16.   TMessageStream = object(TNamedBufStream)
  17.     { This stream prints its name every time anything is read from it. }
  18.  
  19.     procedure read(var buf; size:word); virtual;
  20.   end;
  21.  
  22. procedure TMessageStream.Read;
  23. begin
  24.   writeln('Reading from ',filename^);
  25.   TNamedBufStream.Read(buf,size);
  26. end;
  27.  
  28. var
  29.   stream1, stream2 : PMessageStream;
  30. begin
  31.   ovrinit('ovrdemo.ovr');
  32.  
  33.   writeln('The overlay streams aren''t being used yet.');
  34.  
  35.   proc1;
  36.   proc2;
  37.  
  38.   writeln('Now loading overlays to the two streams.');
  39.  
  40.   ovrclearbuf;    { Make sure no overlay is loaded. }
  41.  
  42.   new(stream1, init('ovrdemo.1',stCreate,2048));
  43.   ovrinitstream(stream1);
  44.  
  45.   proc1;          { This loads proc1 to Stream1, but doesn't trigger a read
  46.                     yet. }
  47.  
  48.   new(stream2, init('ovrdemo.2',stCreate,2048));
  49.   ovrinitstream(stream2);
  50.  
  51.   proc2;          { This loads proc2 to Stream2, but again, no read. }
  52.  
  53.   writeln('Now each unit is on a different stream; let''s call them a few ');
  54.   writeln('times.');
  55.  
  56.   proc1;
  57.   proc2;
  58.   proc1;
  59.   proc2;
  60.  
  61.   writeln('Now the overlay streams will be disposed of.');
  62.  
  63.   OvrDisposeStreams;
  64.  
  65.   writeln('These calls will use the old overlay mechanism.');
  66.   proc1;
  67.   proc2;
  68. end.
  69.  
  70.